<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
 * 差价合约控制器
 * @author [Eason] <[eason_1988@qq.com]>
 * @date(2016-03-31)
 */
class Cfd extends CI_Controller {
	private $productConfig;
	private $user_info;

	public function __construct(){  
        parent::__construct();
        $this->load->config('cfd');
        //加载通行证类
        $this->load->library('passPort');
        $this->passportClass = $this->passport;
        
        $this->passportClass->setPlatform($this->config->item('platform'));//设置平台
		$this->user_info = $this->passportClass->checkCookieAuthCode('','',true);
		
    }

	//交易明细页面
	public function records(){
		if(empty($this->user_info)){
			redirect("/");
		}
		$uid = $this->user_info['uid'];
		$this->load->config('cfd');
		$cfdConfig = $this->config->item('cfdConfig');
		//获取产品详细信息
		$this->load->model('product_model');
		$productData = $this->product_model->getProduct(array('platform'=>'IB', 'status'=>1));
		if(empty($productData)){
			redirect("/");
		}
		$productArr = array();
		foreach($productData as $items){
			$productArr[$items['name']] = $items;
		}
		$start_month = date('Y-m-d 00:00:00',strtotime('-1 month'));
		$this->load->model('cfd_model');
		$tmpData = $this->cfd_model->getTradeLog(array('uid'=>$uid,'date>='=>$start_month),'all','id DESC');
		$records = array();
		if(!empty($tmpData)) foreach($tmpData as $record){
			if(!in_array($record['source'],array(10004,50004,10007,10009))) continue;
			$records[] = $record;
		}

		$assign['user_info'] = $this->user_info;
		$assign['productArr'] = $productArr;
		$assign['records'] = $records;
        $this->load->view('cfd/records',$assign);
	}

	

}
